package com.ioPackage;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * @ClassName CharsetTest
 * @Description 字符集编码解码
 * @Author 2214361854
 * @Date 2022/2/27 18:27
 * @Version 1.0
 */
public class CharsetTest {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String name = "abc我爱你中国";
        byte[] bytes = name.getBytes("GBK");
        System.out.println(bytes.length);
        System.out.println(Arrays.toString(bytes));

        String rs = new String(bytes);
        String rs2 = new String(bytes,"GBK");
        System.out.println(rs);
        System.out.println(rs2);
    }
}
